using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lesson7 : MonoBehaviour
{
    public Transform monster1;
    public Transform monster2;
    void Start()
    {
        #region 四元数相乘
        Quaternion q1 = Quaternion.AngleAxis(20, Vector3.up);
        //累计绕Y轴旋转40度
        monster1.rotation *= q1;
        monster1.rotation *= q1;
        #endregion

        #region 四元数乘向量
        // 使用场景：飞机发现散弹时，子弹使用四元数乘向量
        Vector3 v = Vector3.forward;
        Debug.LogFormat("v log1 v:{0}", v);
        //四元数乘向量,向量一定是写在后面的
        v = Quaternion.AngleAxis(30, Vector3.up) * v;
        Debug.LogFormat("v log2 v:{0}", v, v);
        v = Quaternion.AngleAxis(30, Vector3.up) * v;
        Debug.LogFormat("v log3 v:{0}", v);
        monster2.rotation = Quaternion.LookRotation(v);
        #endregion
    }
}
